define(['app'], function(app) {
	'use strict';

	//实例化方法
	var factory = function(Http) {

		/**
		 * 一键切换数据获取方式
		 * @param {Object} result
		 */
		function get_data_hots_getlist(result) {
			if(false) {
				result = '{"success":true,"msg":"","result":{"page":[{"limit":10,"tPage":50,"cPage":1,"count":1000},{"limit":10,"tPage":50,"cPage":1,"count":1000}],"data":[{"goods_id":"001","name":"一字螺丝刀","price":10.5,"mktprice":10,"preprice":8,"store_id":"001","region":"上大路","store_name":"世达","image":"","salenumber":10},{"goods_id":"002","name":"十字螺丝刀","price":10.5,"mktprice":10,"preprice":8,"store_id":"001","region":"上大路","store_name":"世达","image":"","salenumber":10}]},"session":"7311da98bd0f18eb15a96bcb263f4153"}';
				return JSON.parse(result);
			} else {
				return result;
			}
		}

		//返回信息
		return {
			//搜索商品列表
			search_getlist: function(params, callback, calldone) {
				Http.post({
						method: 'goods.main.search',
						top_search_flag:params.top_search_flag,
						st:params.st,
						scontent: params.scontent,
						brand_id: params.brand_id,
						cat_id: params.cat_id,
						orderby: params.orderby,
						image_url: params.image_url,
						goods_id_search: params.goods_id_search,
						nPage: params.nPage,
						pagelimit: 10
					},
					function(result) {
						//请求成功
						if(callback)
							callback(result);
					},
					function(e) {
						//请求异常
						if(calldone)
							calldone();
					},
					function() {
						//请求完成，一般不做什么事情
						if(calldone)
							calldone();
					}
				);
			},
			//品牌列表
			search_getbrand: function(params, callback) {
				Http.post({
						method: 'member.brand.getall'
					},
					function(result) {
						//请求成功
						if(callback)
							callback(result);
					}
				);
			}
		};
	}

	factory.$inject = ['Http'];
	return app.registerService("Productsearch", factory);
});